(DEFUN simplify (V322)
  (BLOCK NIL
    (TAGBODY
      (IF (CONSP V322)
          (LET ((Cdr336 (CDR V322)))
            (IF (CONSP Cdr336)
                (LET ((Cdr335 (CDR Cdr336)))
                  (IF (CONSP Cdr335)
                      (IF (NULL (CDR Cdr335))
                          (RETURN
                           (s (CAR V322) (simplify (CAR Cdr336))
                              (simplify (CAR Cdr335))))
                          (GO tag331))
                      (GO tag331)))
                (GO tag331))))
     tag331
      (RETURN V322)))) 

(DEFUN s (V326 V327 V328)
  (BLOCK NIL
    (TAGBODY
      (IF (EQ '+ V326)
          (IF (AND (NUMBERP V327) (NUMBERP V328))
              (RETURN (THE NUMBER (+ V327 V328)))
              (IF (EQL 0 V327) (RETURN V328)
                  (IF (EQL 0 V328) (RETURN V327)
                      (IF (CONSP V328)
                          (LET ((Cdr347 (CDR V328)))
                            (IF (EQ '+ (CAR V328))
                                (IF (CONSP Cdr347)
                                    (LET ((Cdr346 (CDR Cdr347)))
                                      (IF (CONSP Cdr346)
                                          (IF (NULL (CDR Cdr346))
                                              (RETURN
                                               (s '+ (s '+ V327 (CAR Cdr347))
                                                  (CAR Cdr346)))
                                              (GO tag337))
                                          (GO tag337)))
                                    (GO tag337))
                                (GO tag337)))
                          (GO tag337))))))
     tag337
      (TAGBODY
        (IF (EQ '* V326)
            (IF (AND (NUMBERP V327) (NUMBERP V328))
                (RETURN (THE NUMBER (* V327 V328)))
                (IF (EQL 0 V327) (RETURN 0)
                    (IF (EQL 0 V328) (RETURN 0)
                        (IF (EQL 1 V328) (RETURN V327)
                            (IF (EQL 1 V327) (RETURN V328)
                                (IF (CONSP V328)
                                    (LET ((Cdr360 (CDR V328)))
                                      (IF (EQ '* (CAR V328))
                                          (IF (CONSP Cdr360)
                                              (LET ((Cdr359 (CDR Cdr360)))
                                                (IF (CONSP Cdr359)
                                                    (IF (NULL (CDR Cdr359))
                                                        (RETURN
                                                         (s '*
                                                            (s '* V327
                                                               (CAR Cdr360))
                                                            (CAR Cdr359)))
                                                        (GO tag348))
                                                    (GO tag348)))
                                              (GO tag348))
                                          (GO tag348)))
                                    (GO tag348))))))))
       tag348
        (RETURN (LIST V326 V327 V328)))))) 

(setq *expr* '(* X (+ (+ (* 12 0) (+ 23 8)) Y)))

(defun tt (N) (gc) (time (test N)))

(defun test (N)
   (cond ((zerop N) 0)
         (t (simplify *expr*) (test (1- N)))))

(mapc 'compile '(tt test simplify s))

;; the benchmark - 10^7 iterations

(tt 10000000)

